const http = require("http");

const mimes = {
  html: "text/html",
  css: "text/css",
  js: "text/javascript",
  png: "image/png",
  jhpg: "image/jpeg",
  gif: "image/gif",
  mp4: "video/mp4",
  mp3: "audio/mpeg",
  json: "application/json",
  down: "application/octet-stream",
};
// setHeader 只针对单一属性的设置、重复设置一个属性会替换之前的设置
const server = http.createServer((req, res) => {
  res.statusCode = 200; // 设置响应状态码 默认200
  res.statusMessage = "ok"; // 响应状态码自定义描述
  res.setHeader("Content-type", `${mimes.html};charset=utf-8`); // html
  res.end("hello");
});
server.listen(8080);
